package com.qf.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.qf.annotation.RequiresPermissionsDesc;
import com.qf.pojo.DtsAccountTrace;
import com.qf.pojo.DtsAddress;
import com.qf.service.DtsAccountTraceService;
import com.qf.service.DtsAdminAddressService;
import com.qf.util.ResponseUtil;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.Map;

/**
 * @author YDW
 * projectName:shop-manage
 * time:2022/5/24 11:43
 * description:
 */
@RestController
@RequestMapping("/admin/address")
public class AdminAddressController {
    @Autowired
    DtsAdminAddressService adminAddressService;


    @RequiresPermissions("admin:address:list")
    @RequiresPermissionsDesc(menu = { "用户管理", "收货地址" }, button = "查询")
    @GetMapping("/list")
    public Object list(
            @RequestParam(name = "page",required = false,defaultValue = "1") Integer page,
            @RequestParam(name = "limit",required = false,defaultValue = "10") Integer limit,
            Integer userId, String name,  String sort, String order
    ){
        IPage<DtsAddress> ipage=adminAddressService.queryPage(page,limit,sort,order,userId,name);
        Map<String,Object> data=new HashMap<>();
        data.put("total",ipage.getTotal());
        data.put("items",ipage.getRecords());
        return ResponseUtil.ok(data);
    }


}
